- DirectiveType
- Directive
- Type
- Restart
- Resume = new Resume()
- Stop = new Stop()
- Escalate = new Escalate()
- Equals (Directive other)
- Equals (object obj)
- GetHashCode ()
- == (Directive lhs, Directive rhs)
- != (Directive lhs, Directive rhs)
- Resume
- Stop
- Restart
- Escalate
- InboxDirective
- MessageDirectiveType
- MessageDirective
- Type
- ForwardToDeadLetters
- ForwardToSelf
- ForwardToParent = new ForwardToParent()
- ForwardTo (ProcessId pid)
- StayInQueue
- Equals (MessageDirective other)
- Equals (object obj)
- GetHashCode ()
- == (MessageDirective lhs, MessageDirective rhs)
- != (MessageDirective lhs, MessageDirective rhs)
- Strategy
- Return <A> (A value)
- Return <A> (Func<StrategyContext, (StrategyContext, A)> f)
- Return (Func<StrategyContext, StrategyContext> f)
- Return <A> (Func<StrategyContext, (TryOption<A>, StrategyContext State)> f)
- Compose (params State<StrategyContext, Unit>[] stages)
- OneForOne (params State<StrategyContext, Unit>[] stages)
- AllForOne (params State<StrategyContext, Unit>[] stages)
- Context = get<StrategyContext>()
- SetDirective (Option<Directive> directive)
- SetFirstFailure (DateTime when)
- SetLastFailure (DateTime when)
- SetBackOffAmount (Time step)
- Pause (Time duration)
- Reset
- MapGlobal (Func<StrategyState, StrategyState> map)
- Identity
- Retries (int Count)
- Retries (int Count, Time Duration)
- Backoff (Time Min, Time Max, Time Step)
- Backoff (Time Min, Time Max, double Scalar)
- Backoff (Time Duration)
- IncFailureCount = MapGlobal(g => g.With(Failures: g.Failures + 1))
- ResetFailureCount = MapGlobal(g => g.With(Failures: 0, FirstFailure: DateTime.MaxValue, LastFailure: DateTime.MaxValue))
- FailedOnce = MapGlobal(g => g.With(Failures: 1, FirstFailure: DateTime.UtcNow, LastFailure: DateTime.UtcNow))
- Always (Directive directive)
- Match (params State<Exception, Option<Directive>>[] directives)
- Redirect (params State<Directive, Option<MessageDirective>>[] directives)
- Redirect (MessageDirective defaultDirective)
- With <TException> (Func<TException, Directive> map)
- With <TException> (Directive directive)
- Otherwise (Func<Exception, Directive> map)
- Otherwise (Directive directive)
- When <TDirective> (Func<TDirective, MessageDirective> map)
- When <TDirective> (MessageDirective directive)
- Otherwise (Func<Directive, MessageDirective> map)
- Otherwise (MessageDirective directive)
- StrategyContext
- Global
- Exception
- Message
- Sender
- Self
- ParentProcess
- Siblings = new ProcessId[0]
- Affects = new ProcessId[0]
- Directive
- MessageDirective
- Pause
- Empty = new StrategyContext( StrategyState.Empty, null, null, ProcessId.None, ProcessId.None, ProcessId.None, null, null, 0 * seconds, None, None)
- With ( StrategyState Global = null, Exception Exception = null, object Message = null, ProcessId? Sender = null, ProcessId? FailedProcess = null, ProcessId? ParentProcess = null, IEnumerable<ProcessId> Siblings = null, IEnumerable<ProcessId> Affects = null, Time? Pause = null, Option<Directive> Directive = default(Option<Directive>), Option<MessageDirective> MessageDirective = default(Option<MessageDirective>) )
- StrategyDecision
- ProcessDirective
- MessageDirective
- Affects
- Pause
- StrategyDecision ( Directive processDirective, MessageDirective messageDirective, IEnumerable<ProcessId> affects, Time pause )
- New ( Directive processDirective, MessageDirective messageDirective, IEnumerable<ProcessId> affects, Time pause )
- StrategyEvent
- StrategyState
- BackoffAmount
- Failures
- FirstFailure
- LastFailure
- Metadata
- Empty = new StrategyState(0 * seconds, 0, DateTime.MaxValue, DateTime.MaxValue, HashMap<string, object>())
- StrategyState ( Time backoffAmount, int failures, DateTime firstFailure, DateTime lastFailure, HashMap<string, object> metadata )
- SetMetaData <T> (string key, T value)
- TrySetMetaData <T> (string key, T value)
- RemoveMetaData <T> (string key)
- MetaDataContains <T> (string key)
- With ( Time? BackoffAmount = null, int? Failures = null, DateTime? FirstFailure = null, DateTime? LastFailure = null, HashMap<string, object>? Metadata = null )
enum DirectiveType Source #
Directive type 'Discriminated union' identifier for the Directive sub-types.
Instruction to the Process system of what action to take when a Process crashes. The directive is assigned to a supervisor who apply these actions to the failed Process and optionally other Processes defined by the Strategy.
field Directive Resume = new Resume() Source #
Resume with state in tact after a crash
field Directive Stop = new Stop() Source #
Shutdown after a crash
field Directive Escalate = new Escalate() Source #
Escalate the exception to the parent of the crashing process' supervisor after a crash
method int GetHashCode () Source #
Returns a unique hash-code for this Directive
returns |
Directive: Resume with state in tact after a crash
Directive: Re-call the setup function to reset the state after a crash.
Directive: Escalate the exception to the parent of the crashing process' supervisor after a crash
enum InboxDirective Source #
enum MessageDirectiveType Source #
class MessageDirective Source #
Message directives This class represents a set of core behaviours for the message that caused a Process to fail.
field MessageDirective ForwardToParent = new ForwardToParent() Source #
Forward the failed message to the supervisor (the parent) of the Process that failed. It will join the back of the queue.
property MessageDirective ForwardToDeadLetters Source #
Forward the failed message onto the Dead Letters process This is the default behaviour
property MessageDirective ForwardToSelf Source #
Forward the failed message back to the Process that failed. It will join the back of the queue.
property MessageDirective StayInQueue Source #
Message remains at the front of the queue for when the process has recovered. Could cause blocking for permanent failures.
field State<StrategyContext, StrategyContext> Context = get<StrategyContext>() Source #
Get the context state State monad
field State<StrategyContext, Unit> IncFailureCount = MapGlobal(g => g.With(Failures: g.Failures + 1)) Source #
Increase the failure count state
field State<StrategyContext, Unit> ResetFailureCount = MapGlobal(g => g.With(Failures: 0, FirstFailure: DateTime.MaxValue, LastFailure: DateTime.MaxValue)) Source #
Reset the failure count state to zero and set FirstFailure and LastFailure to max-value
field State<StrategyContext, Unit> FailedOnce = MapGlobal(g => g.With(Failures: 1, FirstFailure: DateTime.UtcNow, LastFailure: DateTime.UtcNow)) Source #
Set the failure count to 1 and set FirstFailure and LastFailure to UtcNow
method State<StrategyContext, A> Return <A> (Func<StrategyContext, (StrategyContext, A)> f) Source #
method State<StrategyContext, A> Return <A> (Func<StrategyContext, (TryOption<A>, StrategyContext State)> f) Source #
method State<StrategyContext, Unit> Compose (params State<StrategyContext, Unit>[] stages) Source #
Compose a sequence of state computations
method State<StrategyContext, Unit> OneForOne (params State<StrategyContext, Unit>[] stages) Source #
One-for-one strategy This strategy affects only the process that failed
param | stages | Set of computations to compose that results in a behaviour for the strategy |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> AllForOne (params State<StrategyContext, Unit>[] stages) Source #
All-for-one strategy This strategy affects the process that failed and its siblings
param | stages | Set of computations to compose that results in a behaviour for the strategy |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> SetDirective (Option<Directive> directive) Source #
Sets the decision directive. Once set, cant be un-set. If the directive is Stop then the Global state is reset for this strategy (global to the Process)
param | directive | Directive to set |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> SetFirstFailure (DateTime when) Source #
Sets the first-failure state.
param | when | Time to set |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> SetLastFailure (DateTime when) Source #
Sets the last-failure state.
param | when | Time to set |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> SetBackOffAmount (Time step) Source #
Sets the current back off amount
param | step | Step size for the next Process pause before resuming |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> Pause (Time duration) Source #
Pauses the Process for a fixed amount of time
param | duration | Duration of the pause before resuming |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> MapGlobal (Func<StrategyState, StrategyState> map) Source #
Maps the global (to the Process) state.
method State<StrategyContext, Unit> Retries (int Count) Source #
Gives the strategy a behaviour that will only fail N times before forcing the Process to stop
param | Count | Number of times to retry |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> Retries (int Count, Time Duration) Source #
Gives the strategy a behaviour that will only fail N times before forcing the Process to stop. However if a time-peroid of Duration elapses, then the number of failures 'so far' is reset to zero.
This behaviour allows something that's rapidly failing to shutdown, but will allow the occasional failure.
param | Count | Number of times to retry |
param | Duration | Time between failures |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> Backoff (Time Min, Time Max, Time Step) Source #
Applies a strategy that causes the Process to 'back off'. That is it will be paused for an amount of time before it can continue doing other operations.
param | Min | Minimum back-off time |
param | Max | Maximum back-off time; once this point is reached the Process will stop for good |
param | Step | The amount to add to the current back-off time for each failure. That allows for the steps to grow gradually larger as the Process keeps failing |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> Backoff (Time Min, Time Max, double Scalar) Source #
Applies a strategy that causes the Process to 'back off'. That is it will be paused for an amount of time before it can continue doing other operations.
param | Min | Minimum back-off time |
param | Max | Maximum back-off time; once this point is reached the Process will stop for good |
param | Scalar | The amount to multiply the previous back-off time amount for each failure. That allows for the steps to grow gradually larger as the Process keeps failing |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> Backoff (Time Duration) Source #
Applies a strategy that causes the Process to 'back off' for a fixed amount of time. That is it will be paused for an amount of time before it can continue doing other operations. This strategy never causes a Process to be stopped.
param | Duration | Back-off time period |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> Always (Directive directive) Source #
Always return this Directive in the final StrategyDecision
param | directive | Directive to return |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> Match (params State<Exception, Option<Directive>>[] directives) Source #
Match a range of State computations that take the Exception that caused the failure and map it to an Optional Directive. The first computation to return a Some(Directive) will succeed
param | directives | Directive maps |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> Redirect (params State<Directive, Option<MessageDirective>>[] directives) Source #
Match a range of State computations that take the currently selected Directive and map it to an Optional MessageDirective. The first computation to return a Some(MessageDirective) will succeed. If a Directive hasn't been chosen by the time this is invoked then RestartNow is used by default.
param | directives | Directive maps |
returns | Strategy computation as a State monad |
method State<StrategyContext, Unit> Redirect (MessageDirective defaultDirective) Source #
Provides a message redirection strategy that always uses the same MessageDirective regardless of the Directive provided.
param | defaultDirective | Default message directive |
returns | Strategy computation as a State monad |
method State<Exception, Option<Directive>> With <TException> (Func<TException, Directive> map) Source #
Used within the Strategy.Match function to match an Exception to a Directive. Use the function's generic type to specify the type of Exception to match.
type | TException | Type of Exception to match |
param | map | Map from the TException to a Directive |
returns | Strategy computation as a State monad |
method State<Exception, Option<Directive>> With <TException> (Directive directive) Source #
Used within the Strategy.Match function to match an Exception to a Directive. Use the function's generic type to specify the type of Exception to match.
type | TException | Type of Exception to match |
param | directive | Directive to use if the Exception matches TException |
returns | Strategy computation as a State monad |
method State<Exception, Option<Directive>> Otherwise (Func<Exception, Directive> map) Source #
Used within the Strategy.Match function to provide a default Directive if the Exception that caused the failure doesn't match any of the previous With clauses.
param | map | Map from the Exception to a Directive |
returns | Strategy computation as a State monad |
method State<Exception, Option<Directive>> Otherwise (Directive directive) Source #
Used within the Strategy.Match function to provide a default Directive if the Exception that caused the failure doesn't match any of the previous With clauses.
param | directive | Directive to use |
returns | Strategy computation as a State monad |
method State<Directive, Option<MessageDirective>> When <TDirective> (Func<TDirective, MessageDirective> map) Source #
method State<Directive, Option<MessageDirective>> When <TDirective> (MessageDirective directive) Source #
class StrategyContext Source #
Keeps a running context whilst a strategy computation is running
field ProcessId ParentProcess Source #
field IEnumerable<ProcessId> Siblings = new ProcessId[0] Source #
field IEnumerable<ProcessId> Affects = new ProcessId[0] Source #
field Option<MessageDirective> MessageDirective Source #
field StrategyContext Empty = new StrategyContext( StrategyState.Empty, null, null, ProcessId.None, ProcessId.None, ProcessId.None, null, null, 0 * seconds, None, None) Source #
Default strategy context
method StrategyContext With ( StrategyState Global = null, Exception Exception = null, object Message = null, ProcessId? Sender = null, ProcessId? FailedProcess = null, ProcessId? ParentProcess = null, IEnumerable<ProcessId> Siblings = null, IEnumerable<ProcessId> Affects = null, Time? Pause = null, Option<Directive> Directive = default(Option<Directive>), Option<MessageDirective> MessageDirective = default(Option<MessageDirective>) ) Source #
class StrategyDecision Source #
field Directive ProcessDirective Source #
field MessageDirective MessageDirective Source #
constructor StrategyDecision ( Directive processDirective, MessageDirective messageDirective, IEnumerable<ProcessId> affects, Time pause ) Source #
class StrategyEvent Source #
method State<StrategyState, StrategyDecision> Failure ( this State<StrategyContext, Unit> strategy, ProcessId pid, ProcessId sender, ProcessId parent, IEnumerable<ProcessId> siblings, Exception ex, object msg ) Source #
Creates a new State computation that is primed with the data of a particular failure event.
param | strategy | Strategy as a State computation |
param | pid | Process ID that failed |
param | sender | Process that sent the message that cause the failure |
param | parent | Supervisor of the failed Process |
param | siblings | The siblings of the failed Process |
param | ex | Exception |
param | msg | Message that caused the failure |
returns | State computation that can be invoked by passing it an object of StrategyState. This will result in a StateResult that contains the mutated StrategyState and a StrategyDecision. The StrategyDecision contains all the information needed to decide the fate of a Process (and related processes) |
class StrategyState Source #
Holds the 'global' state for a strategy. i.e the state that will survive between invocations of the stratgey computation.
field Time BackoffAmount Source #
field DateTime FirstFailure Source #
field DateTime LastFailure Source #
constructor StrategyState ( Time backoffAmount, int failures, DateTime firstFailure, DateTime lastFailure, HashMap<string, object> metadata ) Source #
method StrategyState SetMetaData <T> (string key, T value) Source #
Adds or updates an item of meta-data
This is for extending the default strategies behaviours and allows for state to survive in-between Process errors
method StrategyState TrySetMetaData <T> (string key, T value) Source #
Attempts to set a meta-data item. If it is already set, nothing happens.
This is for extending the default strategies behaviours and allows for state to survive in-between Process errors
method StrategyState RemoveMetaData <T> (string key) Source #
Attempts to remove a meta-data item. If it is not set, nothing happens.
This is for extending the default strategies behaviours and allows for state to survive in-between Process errors
method bool MetaDataContains <T> (string key) Source #
Returns True if the meta-data contains the key specified